Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implementing language selection #212

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
Open

Conversation

Procyon-b
Copy link
Contributor

It is base the code released to version 0.2.1.
Those who might read this can download and test without fearing any (new) problems outside the added localization code.

Here is a list of modifications so far:

  • updated manifest.js to support localization: future_i18n() tries to get localized string from _T()
  • A bunch of strings in manifest.js now call future_i18n() with 1 or more optional parameters: second arg is the name of the message, and other args are placeholders (used a couple times). future_i18n() is still compatible with old usage to support messages not yet localized.
  • Newly localized "settings" page's messages are not included in the EN locale (since they are defined in setting_definitions).
  • FR locale contains all text from the "settings" page.
  • settings page: the "language" block under "appearance" has been refined. The textarea for the user-defined locale is hidden by default. A button appears next to the "select" element only when "user defined" is selected. Clicking this button toggles the display of the textarea.
  • To handle this behaviour, __custom.css contains style to move the button next to the select (float) and to hide these elements.
    code in setting.js adds CSS classes to these elements (CSS classes can't be added by editing setting_definitions), and defines event-based functions to handle user actions (using CSS classes).

To get a full overview, select the french locale and reload the settings page.
Users who would like to translate the settings page in their language can base it on the FR locale file. Unfortunately I have not yet added the "description" element to the new messages, But they are defined in the order of appearance in the page, and their name is a hint of what they do.

Edit your locale in a text editor and paste it regularly in the form element for "user-defined" locale. Refresh the page. If you make syntax errors (unescaped quotes in messages, error in JSON syntax), the locale will be ignored and the english locale is selected.
Also, if the user-locale is incomplete, it is completed with messages from the english locale.

Create a new branch based on current code "rc" (as of 20200429).
Update files for language selection support
added "settings" messages
added localized string
handling of "locale selection" form's elements
modified function to handle i18n localization
added style for "select language" form elements
@Procyon-b
Copy link
Contributor Author

Procyon-b commented May 5, 2020

I thought that it could be a good idea to add a "refresh this page" button in the appearance tab, at the top in the unnamed section. But when reloading, the focus moves to the welcome tab.

I've looked at the code, and found that it is possible to load a specific tab. If only selecting a tab also updates the #open= part of the url.
Do you know if there is an option to activate this?

I've tested with my own code, and the # is correctly updated. CTRL-R or F5 now reloads the correct tab. So no need for the reload button after all. But may be a "reload all TF" to stay focused on the settings page while reload TF's window and the settings page.

Do I add the code to update the location.hash in this PR?

@cxw42
Copy link
Owner

cxw42 commented Dec 25, 2020

@Procyon-b Sorry for the long delay in responding! For "refresh this page" / location.href, please include that in a separate PR if you would like to submit the code. I would like to keep this PR focused on the language support. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants